﻿using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Percount : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        List<SqlDb.Employees> rs = null;
        DataSet rs2 = null;
        long[] count1 = new long[5];
        long[] count2 = new long[5];
        Stopwatch wt = new Stopwatch();
        for (int i = 0; i < 5; i++)
        {
            wt.Start();
            for (int j=0; j < 100; j++)
            {
                rs = EmployeeMoudle.GetEmployees();
            }
            wt.Stop();
            count1[i] = wt.ElapsedMilliseconds;
            wt.Reset();
        }

        for (int i = 0; i < 5; i++)
        {
            wt.Start();
            for (int j = 0; j < 100; j++)
            {
                rs2 = EmployeeMoudle.GetEmployeeByAdo();
            }
            wt.Stop();
            count2[i] = wt.ElapsedMilliseconds;
            wt.Reset();
        }


        Response.Write("Query2Object 测试结果：");
        for (int i = 0; i < 5; i++)
        {
            Response.Write("第" + (i + 1) + "次（");
            Response.Write(count1[i].ToString());
            Response.Write("）毫秒  ");
        }
        Response.Write("<br/> 平均：");
        Response.Write((count1[0] + count1[1] + count1[2] + count1[3] + count1[4]) / 5);
        Response.Write("秒<br />");
        Response.Write("Ado.NETDataSet测试结果：");
        for (int i = 0; i < 5; i++)
        {
            Response.Write("第" + (i + 1) + "次（");
            Response.Write(count2[i].ToString());
            Response.Write("）毫秒  ");
        }
        Response.Write("<br/> 平均：");
        Response.Write((count2[0] + count2[1] + count2[2] + count2[3] + count2[4]) / 5);
        Response.Write("秒<br />");
    }
}
